package com.ilop.sthome.data.enums;

import com.siterwell.familywellplus.R;

import java.util.Arrays;

/**
 * @author skygge
 * @date 2020-01-01.
 * GitHub：javofxu@github.com
 * email：skygge@yeah.net
 * description：所有产品最小细胞/类型/名称/分数/型号
 */

public enum ProductGroup {

    /**
     * 智能网关(1)
     */

    // 网关
    EE_DEV_GATEWAY(0, CellsEnum.SMART_GATEWAY, R.string.ali_gateway,
            R.mipmap.gs198,10f, "GS198D", "GS198A"),

    /**
     * 智能消防(2)
     */

    //SM报警器
    EE_DEV_SM_ALARM(1, CellsEnum.SMART_SM_ALARM,  R.string.smalarm,
            R.mipmap.gs530, 9f, "GS530D", "GS530D"),

    //CO报警器
    EE_DEV_CO_ALARM(1, CellsEnum.SMART_CO_ALARM,  R.string.coalarm,
            R.mipmap.gs816, 7.2f, "GS816A", "GS816A"),

    //燃气报警器
    EE_DEV_GAS_ALARM(1, CellsEnum.SMART_GAS_ALARM,  R.string.gasalarm,
            R.mipmap.gs870w, 9f, "GS870W", "GS870W"),

    //热感报警器
    EE_DEV_THERM_ALARM(1, CellsEnum.SMART_THERM_ALARM,  R.string.thermalalarm,
            R.mipmap.gs412, 7.2f, "GS412D", "GS412A"),

    //水感报警器
    EE_DEV_WT_ALARM(1, CellsEnum.SMART_WT_ALARM,  R.string.wt,
            R.mipmap.gs156, 8.1f, "GS156D", "GS156A"),

    //复合型报警器
    EE_DEV_SX_SM_ALARM(1, CellsEnum.SMART_SX_ALARM,  R.string.cxsmalarm,
            R.mipmap.gs592, 16.2f, "GS559A", "GS559A"),

    //新燃气报警器
    EE_DEV_NEW_GAS_ALARM(1, CellsEnum.SMART_NEW_GAS_ALARM,  R.string.gasalarm,
            R.mipmap.gs871, 9f, "GS871A", "GS871A"),

    //CO&GAS报警器
    EE_DEV_CO_GAS_ALARM(1, CellsEnum.SMART_CO_GAS_ALARM,  R.string.co_and_gas_alarmer,
            R.mipmap.gs871, 16.2f, "GS891A", "GS891A"),

    //震动闪光报警器
    EE_DEV_FLASH_ALARM(1, CellsEnum.SMART_FLASH_ALARM,  R.string.vibration_flash_compound_alarm,
            R.mipmap.gs163, 5f, "GS163D", "GS163D"),

    //机械手
    EE_DEV_MANIPULATOR(1, CellsEnum.SMART_MANIPULATOR,  R.string.manipulator,
            R.mipmap.gs970, 5f, "GS970A", "GS970A"),

    //电磁阀
    EE_DEV_SOLENOID_VALVE(1, CellsEnum.SMART_SOLENOID_VALVE,  R.string.solenoid_valve_controller,
            R.mipmap.gs972, 5f, "GS972A", "GS972A"),
    /**
     * 智能防盗(3)
     */

    //人体移动探测器
    EE_DEV_PIR(2, CellsEnum.SMART_PIR,  R.string.pir,
            R.mipmap.gs300d, 8f, "GS300D", "GS300A"),

    // 门磁
    EE_DEV_DOOR(2, CellsEnum.SMART_DOOR,  R.string.door,
            R.mipmap.gs320d,8f, "GS320D", "GS320A"),

    //SOS按钮
    EE_DEV_SOS(2, CellsEnum.SMART_SOS,  R.string.soskey,
            R.mipmap.gs390, 6.4f, "GS390D", "GS390A"),

    //室外警笛
    EE_TEMP_OUTDOOR_SIREN(2, CellsEnum.SMART_OUTDOOR,  R.string.outdoor_siren,
            R.mipmap.gs380, 6.4f, "GS380D", "GS380A"),

    // 摄像头
    EE_DEV_IPC(2, CellsEnum.SMART_CAMERA,  R.string.ali_camera,
            R.mipmap.gs290,8f, "GS290", "GS290"),

    //门锁
    EE_DEV_LOCK(2, CellsEnum.SMART_DOOR_LOCK,  R.string.lock,
            R.mipmap.gs920, 8f, "GS920D", "GS920A"),

    /**
     * 智能环境(4)
     */

    //智能插座
    EE_DEV_SOCKET(3, CellsEnum.SMART_SOCKET,  R.string.socket,
            R.mipmap.gs350,5f, "GS350D", "GS350A"),

    //按键
    EE_DEV_BUTTON(3, CellsEnum.SMART_BUTTON,  R.string.button,
            R.mipmap.gs585, 4f, "GS585D", "GS585A"),

    //场景开关
    EE_DEV_MODE_BUTTON(3, CellsEnum.SMART_SCENE_SWITCH,  R.string.mode_button,
            R.mipmap.gs584, 4f, "GS584D", "GS584A"),

    //开关模块
    EE_DEV_LIGHTING_MODULE(3, CellsEnum.SMART_LIGHTING_MODULE,  R.string.lamp_model,
            R.mipmap.gs344, 4f, "GS971D", "GS971A"),

    //温湿度探测器
    EE_DEV_TH_CHECK(3, CellsEnum.SMART_TH_CHECK,  R.string.thcheck,
            R.mipmap.gs240d, 2.5f, "GS240D", "GS240A"),

    //温控器
    EE_TEMP_CONTROL(3, CellsEnum.SMART_CONTROL,  R.string.temp_controler,
            R.mipmap.gs361, 4f, "GS361D", "GS361A");


    private String[] devType;

    private int smartType;

    private int devResId;

    private int drawResId;

    private float fraction;

    private String modelHm;

    private String modelAb;

    ProductGroup(int smartType, String[] devType, int resId, int iconId, float fraction, String modelHm, String modelAb) {
        this.devType = devType;
        this.smartType = smartType;
        this.devResId = resId;
        this.drawResId = iconId;
        this.fraction = fraction;
        this.modelHm = modelHm;
        this.modelAb = modelAb;
    }

    public int getDeviceType() {
        return smartType;
    }

    /**
     * 获取设备类型的字符串ID
     *
     * @return 设备类型字符串ID
     */
    public int getTypeStrId() {
        return this.devResId;
    }

    /**
     * 获取设备图标的资源ID
     * @return
     */
    public int getDrawableResId() {
        return this.drawResId;
    }

    /**
     * 获取分数
     * @return
     */
    public float getFraction() {
        return fraction;
    }

    /**
     * 获取设备类型的索引号
     *
     * @return
     */
    public String[] getDevType() {
        return this.devType;
    }

    /**
     * 国内产品型号
     * @return
     */
    public String getModelHm() {
        return modelHm;
    }

    /**
     * 国外产品型号
     * @return
     */
    public String getModelAb() {
        return modelAb;
    }

    public static ProductGroup getType(String devType) {
        for (ProductGroup productGroup : ProductGroup.values()) {
            if (Arrays.asList(productGroup.devType).contains(devType)){
                return productGroup;
            }
        }
        return null;
    }
}
